home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 3 / Cream of the Crop 3.iso / utility / mu17_ext.zip / LOGINMAI.BAK < prev    next >
Text File  |  1994-03-07  |  4KB  |  168 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <ctype.h>
  5. #include <exec/ports.h>
  6. #include <exec/memory.h>
  7. #include <exec/types.h>
  8. #include <exec/interrupts.h>
  9. #include <devices/input.h>
  10. #include <intuition/intuition.h>
  11. #include <proto/all.h>
  12. #include <clib/exec_protos.h>
  13. #include <clib/alib_protos.h>
  14. #include <clib/intuition_protos.h>
  15.  
  16.  
  17. #include "headers/global.h"
  18. #include "headers/deamon.h"
  19. #include "headers/talkto_proto.h"
  20. #include "headers/login.h"
  21. #include "headers/login_proto.h"
  22. #include "headers/error_proto.h"
  23.  
  24. #if (DEBUG)
  25.     void main()
  26. #else 
  27.     void __main(argv) 
  28.     char    *argv;
  29. #endif
  30. {
  31.     char            Pass[MAXPOS+1];
  32.     char            DispPass[MAXDISP+1]="                      ";
  33.     char            PPos=0,PPDisp=0;
  34.     unsigned long        Status=-1;
  35.     struct IntuitionBase     *IntuiBase;
  36.     struct Window        *window=NULL;
  37.     void*            address;
  38.     ULONG            class;
  39.     USHORT            key1,key2;
  40.     struct IntuiMessage *    my_message;
  41.     BOOL            accept = FALSE;
  42.     BOOL            PassWord=FALSE;
  43.  
  44.     if (!(IntuiBase = (struct IntuitionBase *)OpenLibrary("intuition.library",NULL))) {
  45.         Error("Cannot Open Intuition.library");
  46.         exit(10);
  47.     }
  48.     
  49.     if (!(window = OpenWindow(&NewWindowStructure1))) {
  50.         Error("cannot Open the Window");
  51.         exit(15);
  52.     }
  53.  
  54.     INITKillButtons();
  55.  
  56.     Gadget2.GadgetText->IText = DispPass;
  57.  
  58.     do {
  59.         SetWindowTitles(window,NULL,LOGINVER);
  60.         PrintIText(window->RPort,&IntuiTextList1,0,0);
  61.  
  62.         ActivateGadget(&Gadget1,window,NULL);
  63.         Gadget1.Flags |= SELECTED;
  64.         RefreshGadgets(&Gadget1,window,NULL);
  65.  
  66.         while (!accept) {
  67.             Wait(1<<window->UserPort->mp_SigBit);
  68.             WindowToFront(window);
  69.             ActivateWindow(window);
  70.  
  71.                 while (my_message = (struct IntuiMessage *) GetMsg(window->UserPort )) {
  72.                       class = my_message->Class;      /* Save the IDCMP flag. */
  73.                       address = my_message->IAddress; /* Save the address. */
  74.       
  75.                 key1 = my_message->Code;
  76.                 my_message->Code = 0;
  77.                 key2 = my_message->Qualifier;
  78.                 my_message->Qualifier = 0;
  79.                       ReplyMsg((struct Message*) my_message );
  80.                 
  81.                 if (class == IDCMP_INTUITICKS) {
  82.                     WindowToFront(window);
  83.                     ActivateWindow(window);
  84.                 }
  85.                 if (class==IDCMP_GADGETUP) {
  86.                     if (address == &Gadget2) {
  87.                         PassWord = !PassWord;
  88.                         Gadget1.Flags &= ~SELECTED;
  89.                         RefreshGadgets(&Gadget1,window,NULL);
  90.                     }
  91.                     else if (address == &Gadget1) {
  92.                         PassWord = TRUE;
  93.                         Gadget2.Flags |= SELECTED;
  94.                         Gadget1.Flags &= ~SELECTED;
  95.                         RefreshGadgets(&Gadget1,window,NULL);
  96.                     }
  97.                 }
  98.                 else if (class == IDCMP_GADGETDOWN) {
  99.                     if (address == &Gadget1) {
  100.                         Gadget1.Flags |= SELECTED;
  101.                         Gadget2.Flags &= ~SELECTED;
  102.                         RefreshGadgets(&Gadget1,window,NULL);
  103.                         PassWord = FALSE;
  104.                     }
  105.                 }
  106.                 else if (class == IDCMP_RAWKEY || class == IDCMP_VANILLAKEY) {
  107.                     if (class == IDCMP_RAWKEY) {
  108.                         break;
  109.                     }
  110.                     if (PassWord) {
  111.                         if ((key1 == CR)||(key1 == NL)) {
  112.                             accept = TRUE;
  113.                         }
  114.                         if (isprint(key1)) {
  115.                             if (PPos < MAXPOS) {
  116.                                 Pass[PPos++] = key1;
  117.                                 Pass[PPos] = NULL;
  118.                                 if (PPDisp < MAXDISP) {
  119.                                     DispPass[PPDisp++] = '*';
  120.                                     DispPass[PPDisp] = NULL;
  121.                                 }
  122.                             }
  123.                             else DisplayBeep(NULL);
  124.                         }
  125.                         if (key1 == BS) {
  126.                             if (PPos > 0) {
  127.                                 Pass[--PPos] = NULL;
  128.                                 if (PPDisp > PPos) {
  129.                                     DispPass[--PPDisp] = NULL;
  130.                                 }
  131.                             }
  132.                             else DisplayBeep(NULL);
  133.                         }
  134.                         RefreshGadgets(&Gadget1,window,NULL);
  135.                     }
  136.                 }
  137.                 else if ((class == IDCMP_MOUSEBUTTONS)||(class == IDCMP_INACTIVEWINDOW)) {
  138.                     ActivateGadget(&Gadget1,window,NULL);
  139.                     Gadget1.Flags |= SELECTED;
  140.                     RefreshGadgets(&Gadget1,window,NULL);
  141.                     WindowToFront(window);
  142.                     ActivateWindow(window);
  143.                 }
  144.             }
  145.         }
  146.         RestoreButtons();
  147.  
  148.             /* this is the module you will need to change for the
  149.                 to work on the MUFS, change talkto to muCheckPassword();
  150.                 the Gadget1SIBuff == user name;
  151.                     Pass          == password;
  152.                     OK           == 0 (or false);
  153.                     and if status == 0 the system exits.
  154.  
  155.                 ie 
  156.  
  157.                     OK = !muCheckPass(); 
  158.             */
  159.         Status = TalkTo(Gadget1SIBuff,Pass,NULL ,LOGIN); 
  160.         KillButtons();
  161.         accept = FALSE;
  162.         if (!(Status == OK)) DisplayBeep(NULL);
  163.     } while (!(Status == OK));
  164.     FINALRestoreButtons();
  165.     CloseWindow(window);
  166.     CloseLibrary((struct Library *) IntuiBase);
  167. }
  168.